﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using BUS;

namespace GUI
{
    public partial class DangNhap : Form
    {
        public DangNhap()
        {
            InitializeComponent();
        }
        public int loai;
        private void DangNhap_Load(object sender, EventArgs e)
        {
            rderror.Checked = true;
            this.ActiveControl = txttendn;
        }

        private void txtreset_Click(object sender, EventArgs e)
        {
            this.txttendn.Text = "";
            this.txtmk.Text = "";
            this.txttendn.Focus();
        }

        private void btlogin_Click(object sender, EventArgs e)
        {
            //bool dn;
            //if (rderror.Checked == true)
            //{
            //    dn = false;
            //}
            //else
            //{
            //    dn = true;
            //}
            DangNhapBUS dnBUS = new DangNhapBUS();
            if (dnBUS.KiemTraDangNhap(txttendn.Text, txtmk.Text))
            {
                this.Visible = false;
                Form1 frm = new Form1();
                frm.ShowDialog();

            }
            else
            {
                MessageBox.Show("Đăng nhập thất bại!");
            }
            //string tdn = txttendn.Text;
            //string mk = txtmk.Text;
            //if (rdfix.Checked == true)
            //{
            //    loai = 1;
            //}
            //else
            //{
            //    loai = 0;
            //}
            //List<NhanVienDTO> login = new NhanVienBUS().LoadUser(loai, user, pass);
            //int count = login.Count;
            //MessageBox.Show(count.ToString());
            //if (count == 0)
            //{
            //    MessageBox.Show("Khong ton tai User.Xin kiem tra lai.....");

            //}
            //else
            //{
            //    MessageBox.Show("Xin chao " + txttendn.Text);

            //    Form1 main = new Form1();
            //    main.Show();
            //}
        }
    }
}
